#!/usr/bin/python 

from flask import Flask,render_template,url_for,request
import motor


app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/car',methods=['POST','GET'])
def car():
	ctl=request.args.get('ctl')
	print(ctl)

	if ctl == 'up':
		motor.up()

	if ctl == 'down':
		motor.down()

	if ctl == 'left':
		motor.left()

	if ctl == 'right':
		motor.right()
		
	if ctl == 'stop':
		motor.stop()

	return ctl

if __name__ == '__main__':
    app.debug = True #
    app.run(host='0.0.0.0')
